﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 泛型集合类List
{
    class Student
    {
        public string name;
        public int age;
        public void Info()
        {
            Console.WriteLine("姓名={0}，年龄={1}", name, age);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            List<Student> list1=new List<Student>();   
            Student stu = new Student();
            stu.name = "小明";
            stu.age = 1;
            list1.Add(stu);  //将对象stu添加刀list1的结尾处
            Student stu1 = new Student();
            stu1.name = "小红";
            stu1.age = 2;
            list1.Add(stu1);
            foreach (Student stutemp in list1)   //查找list1中Student类的对象
            {
                stutemp.Info();    //调用对象方法
            }
        }
    }
}
